<template>
  <div class="search-box">
    <div class="search-left">
      宝贝
      <i class="el-icon-s-flag" style="color: red;"></i>
    </div>
    <div class="search-box">
      <i class="el-icon-search" v-if="searchicon"></i>
      <input type="text" ref="inp" placeholder="请输入宝贝描述..." :class="{ suojin: issuojin }" v-model.trim="content" @keyup="inputitem" @blur="show" />
      <button @click="search">搜索</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchicon: true,
      content: '',
      issuojin: false
    }
  },
  methods: {
    inputitem() {
      this.searchicon = false
      this.$refs.inp.placeholder = ''
      this.issuojin = true
    },
    show() {
      this.searchicon = true
      this.issuojin = false
      this.$refs.inp.placeholder = '请输入宝贝描述...'
    },
    search() {
      this.$emit('search', this.content)
    }
  }
}
</script>

<style lang="less" scoped>
.search-box {
  width: 628px;
  height: 40px;
  border: 1px solid #ff5000;
  background: #fff;
  border-radius: 20px;
  .search-left {
    float: left;
    user-select: none;
    width: 74px;
    height: 38px;
    line-height: 38px;
    color: #333;
    font-weight: 400;
    font-size: 14px;
    opacity: 0.75;
    text-align: center;
    border-right: 1px solid #eae8eb;
    .aixin {
      font-size: 12px;
    }
  }
  .search-box {
    float: right;
    width: 551px;
    height: 38px;
    overflow: hidden;
    border: transparent;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 8px;
      top: 12px;
    }
    input {
      width: 470px;
      height: 100%;
      text-indent: 2em;
      outline: none;
      border: transparent;
    }
    .suojin {
      text-indent: 0;
    }
    button {
      outline: none;
      height: 38px;
      width: 76px;
      border: transparent;
      background: linear-gradient(45deg, #ff9000, #ff5000);
      font-size: 18px;
      font-weight: 700;
      border-radius: 19px;
      cursor: pointer;
      color: #fff;
      &:active {
        background: linear-gradient(45deg, #e68f1e, #ff5000);
      }
    }
  }
}
</style>
